package br.com.fafica.sisape.view;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Color;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;

import br.com.fafica.sisape.control.ControllerClinica;
import br.com.fafica.sisape.control.ControllerHospital;
import br.com.fafica.sisape.control.ControllerMedico;
import br.com.fafica.sisape.control.ControllerTelas;
import br.com.fafica.sisape.control.ControllerUsuario;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class TelaEscolherModo extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					TelaEscolherModo frame = new TelaEscolherModo();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public TelaEscolherModo() {
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 520, 160);
		contentPane = new JPanel();
		contentPane.setBackground(Color.WHITE);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblEmQueModo = new JLabel("Em que modo deseja executar o sistema?");
		lblEmQueModo.setForeground(new Color(0, 0, 128));
		lblEmQueModo.setFont(new Font("Times New Roman", Font.PLAIN, 18));
		lblEmQueModo.setBounds(25, 39, 318, 19);
		contentPane.add(lblEmQueModo);
		
		final JComboBox comboEscolha = new JComboBox();
		comboEscolha.setModel(new DefaultComboBoxModel(new String[] {"...", "Teste", "MySql", "Outra"}));
		comboEscolha.setForeground(new Color(0, 0, 128));
		comboEscolha.setFont(new Font("Times New Roman", Font.PLAIN, 14));
		comboEscolha.setBounds(337, 35, 137, 29);
		contentPane.add(comboEscolha);
		
		JButton btnOk = new JButton("OK");
		btnOk.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String escolha = (String) comboEscolha.getSelectedItem();
				if(escolha.equals("Teste")){
					
					ControllerUsuario control = new ControllerUsuario();
					ControllerMedico control1 = new ControllerMedico();
					ControllerHospital control2 = new ControllerHospital();
					ControllerClinica control3 = new ControllerClinica();
					control.modo = escolha;
					control1.modo = escolha;
					control2.modo = escolha;
					control3.modo = escolha;
					ControllerTelas controlTela = new ControllerTelas();
					dispose();
				}else if(escolha.equals("MySql")){
					TelaDadosDoBanco telaBanco = new TelaDadosDoBanco();
					telaBanco.setLocationRelativeTo(null);
					telaBanco.setVisible(true);
					ControllerUsuario control = new ControllerUsuario();
					ControllerMedico control1 = new ControllerMedico();
					ControllerHospital control2 = new ControllerHospital();
					ControllerClinica control3 = new ControllerClinica();
					control.modo = escolha;
					control1.modo = escolha;
					control2.modo = escolha;
					control3.modo = escolha;
					dispose();
					
				}else{
					
				}
			}
		});
		btnOk.setBounds(210, 79, 89, 29);
		contentPane.add(btnOk);
	}
}
